    const webpackMerge = require('webpack-merge');
    const webpack = require('webpack');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    const ip = require('ip').address();
    const baseConfig = require('./config/base');
    const config = require('./config/config');
    const defPath = config.defPath;
    const APP_PATH = defPath.APP_PATH;

    const Dashboard = require('webpack-dashboard');
    const DashboardPlugin = require('webpack-dashboard/plugin');
    const dashboard = new Dashboard();

    // 使用 `webpack-merge` 将基础配置和新配置合并
    module.exports = webpackMerge(baseConfig(), {
        devtool: 'cheap-module-source-map', // 增强浏览器调试
        entry: {    // 入口
            app: [  // 热加载配置
                // 'react-hot-loader',
                'webpack-dev-server/client?http://' + ip + ':8888',
                'webpack/hot/only-dev-server',
                defPath.ENTRY_PATH
            ],
            vendor: config.vendor   // 公共文件单独打包
        },
        output: {   // 出口
            path: defPath.DEV_PATH,     // 所有输出文件的目标路径
            // 所有输出文件的目标路径
            filename: 'js/bundle.js',   // 输出文件命名
            publicPath: '/',        // 必须写，且与 devServer 的 publicPath 保持一致
            chunkFilename: 'js/[name].js'  // 分块文件命名
        },
        module: {
            rules: [
                {
                    test: /\.jsx?$/,
                    exclude: /node_modules/,
                    loader: 'babel-loader',
                    options: {
                      cacheDirectory: true,
                      presets: ['env', 'stage-2', 'react'],
                      plugins: ['transform-runtime'],
                    },
                },
                {
                    test: /\.(less|css)$/,
                    use: [
                      {
                        loader: 'style-loader',
                      },
                      {
                        loader: 'css-loader',
                        options: {
                          minimize: false,
                          sourceMap: true,
                        },
                      },
                      {
                        loader: 'less-loader',
                        options: {
                          sourceMap: true,
                        },
                      },
                    ],
                },
                {
                    test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif|mp4|webm)(\?\S*)?$/,
                    include: APP_PATH,
                    loader: 'url-loader?limit=8192&name=images/[name].[ext]'
                },
                {
                    test:/\.html$/,
                    loader: 'html-withimg-loader?' + JSON.stringify({
                             attrs: ['img:src']})

                },
            ]
        },
        plugins: [
            // 热模块替换相关插件
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NamedModulesPlugin(),

            new DashboardPlugin(dashboard.setData),
            // 定义环境变量
            new webpack.DefinePlugin({
                'process.env.NODE_ENV': JSON.stringify('development')
            }),
            /*
                公用模块单独打包，对应 入口文件 vendor,
                持久化缓存配置
            */
            new webpack.optimize.CommonsChunkPlugin({
                names: [    // 提取公共模块名称
                    'vendor' // manifest 用于分离 webpack runtime
                ],
                filename: 'js/[name].js', // 公共模块文件名
                minChunks: Infinity     // Infinity 表示仅仅创建公共组件块，不会把任何modules打包进去。
            }),
             new ExtractTextPlugin({
                filename: 'css/styles.css',
                disable: false,
                allChunks: true
            })
          //   new ChunkManifestPlugin({   // 将 manifest 提取到一个单独的 JSON 文件中
          //    filename: 'chunk-manifest.json',
          //    manifestVariable: 'webpackManifest' // 全局变量的名称，webpack 将利用它查找 manifest JSON 对象
          // })
        ],
        devServer: {    // 开启服务器
            contentBase: defPath.DEV_PATH,
            publicPath: '/',
            historyApiFallback: true,
            clientLogLevel: 'none',
            host: ip,
            port: 8888,
            open: true,
            hot: true,
            quiet: true,
            inline: true,
            compress: true,
            stats: {
                colors: true,
                errors: true,
                warnings: true,
                modules: false,
                chunks: false
            },
            proxy: {
                '/': 'http://192.168.1.201/wedding.com/index.php/'
            }
        }
    });